package com.yazq.controller;

import com.yazq.pojo.Emp;
import com.yazq.pojo.Emp_expr;
import com.yazq.pojo.PageResult;
import com.yazq.pojo.Result;
import com.yazq.service.EmpService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDateTime;
import java.util.List;

@RestController
@RequestMapping("/emps")
public class EmpController {
    @Autowired
    private EmpService empService;
    @GetMapping
    public Result getEmps(String name, Integer gender,
                          @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDateTime begin,
                          @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDateTime end,
                          @RequestParam(defaultValue = "1") Integer page,
                          @RequestParam(defaultValue = "10") Integer pageSize){
        PageResult<Emp> result = empService.getEmpInfoService(name, gender, begin, end,page, pageSize);
        return Result.success(result);
    }
    @PostMapping
    public Result addEmp(@RequestBody Emp user){

        empService.addEmp(user);
        return Result.success();
    }
}
